<?php

/*
 * @Date: 2025-08-19 23:02:47
 * @LastEditors: 贾二小 erxiao.jia@outlook.com
 * @LastEditTime: 2025-10-28 21:16:06
 * @FilePath: /admin-api/app/Http/Requests/UpdateUserRequest.php
 */

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UpdateUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'name' => 'max:100',
            'real_name' => 'max:100',
            'mobile' => ['nullable', 'max:20', Rule::unique('users')->ignore(request('id'))],
            'email' => ['nullable', 'max:255', Rule::unique('users')->ignore(request('id'))],
            'gender' => [Rule::in([0, 1, 2])],
        ];
    }
}
